package crp.services.api.graphql.models;

import com.qwlabs.lang.C2;
import crp.core.course.domain.models.CourseEntity;
import crp.core.resource.domain.models.AttachmentType;
import crp.core.resource.domain.models.CreateCourseResourceCommand;
import crp.core.resource.domain.models.ResourceSourceType;
import com.qwlabs.storage.models.StorageObject;
import lombok.Getter;
import lombok.Setter;
import org.eclipse.microprofile.graphql.Input;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

@Input("CreateResourceInput")
@Getter
@Setter
public class CreateCourseResourceInput {
    @NotBlank
    private String courseId;
    @NotBlank
    private String name;
    @NotNull
    private AttachmentType type;
    @NotEmpty
    private List<StorageObject> attachments;


    public CreateCourseResourceCommand of(CourseEntity course) {
        return CreateCourseResourceCommand.builder()
                .course(course)
                .sourceType(ResourceSourceType.SELF_BUILD)
                .name(name)
                .type(type)
                .items(attachments)
                .build();
    }

}
